package com.xcl.Controller;

import com.xcl.entity.Area;
import com.xcl.redis.RedisUtil;
import com.xcl.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.ws.rs.ConstrainedTo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Controller
 *
 * @author 徐长乐
 * @date 2019/10/30
 */
@Controller
@RequestMapping("hello")
public class testController {
    @Autowired
    private AreaService areaService;
    @Autowired
    RedisUtil redisUtil;
    @Autowired
    MongoTemplate mongoTemplate;
    @RequestMapping("index")
@ResponseBody
    public String hello(){
        List<Area> areaList = new ArrayList<Area>();
        Area area=new Area();
        area.setAreaName("11");
        area.setAreaId(1);
        area.setCreateTime(new Date());
        areaList = areaService.getAreaList();
        redisUtil.set("aa1","aaaa");
        mongoTemplate.insert(area,"stus");
        return String.valueOf(areaList.size());
    }
}
